import axios from "axios";
import config from "../../config";
import { ElMessage } from "element-plus";

const service = axios.create({
    baseURL: config.service.baseURL,
    timeout: 200000
});

service.interceptors.request.use(
    request => {
        request.headers["Authorization"] = "123";
        return request;
    },
    error => {
        ElMessage.error(error.message);
    }
);

service.interceptors.response.use(
    response => {
        const res = response.data;
        return res;
    },
    error => {
        ElMessage.error(error.response.data.message);
    }
);

export default service;    